package com.xiaotao.controller;

import com.xiaotao.entity.UserSign;
import com.xiaotao.service.UserSignService;
import com.xiaotao.util.ResponseUtil;
import com.xiaotao.util.UserUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sign")
public class UserSignController {
    @Resource
    private UserSignService userSignService;

    @PostMapping
    public ResponseUtil add(@RequestBody UserSign userSign) throws Exception {
        return userSignService.add(userSign);
    }

    @GetMapping
    public ResponseUtil queryAll() throws Exception {
        Integer userId = UserUtil.UserContext();
        return userSignService.queryAll(userId);
    }

    @GetMapping("/userId")
    public ResponseUtil queryByUserId() throws Exception {
        Integer userId = UserUtil.UserContext();
        return userSignService.queryByUserId(userId);
    }
}
